home *** CD-ROM | disk | FTP | other *** search
/ Aminet 28 / Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso / Aminet / dev / misc / gms_dev.lha / GMSDev / Source / Asm / Blitter / Transparent.s < prev   
Encoding:
Text File  |  1998-05-17  |  6.6 KB  |  295 lines

  1. ;-------T-------T------------------------T----------------------------------;
  2. ;This an example of 3 circles blitted onto a planar screen at different
  3. ;levels of depth.  Move the green circle over the bouncing circles to get
  4. ;an idea of the effects you can achieve with a planar screen.
  5. ;
  6. ;The screen is double buffered and interlaced, just to be a bit different
  7. ;from the other demos.  The circles are removed from the screen using the
  8. ;CLEAR mode and a restore list.
  9.  
  10.     INCDIR    "GMSDev:Includes/"
  11.     INCLUDE    "dpkernel/dpkernel.i"
  12.  
  13.     SECTION    "Demo",CODE
  14.  
  15. ;===========================================================================;
  16. ;                             INITIALISE DEMO
  17. ;===========================================================================;
  18.  
  19.     STARTDPK
  20.  
  21. Start:    MOVEM.L    A0-A6/D1-D7,-(SP)
  22.     move.l    DPKBase(pc),a6
  23.  
  24.     ;Load the Circle.
  25.  
  26.     lea    TAGS_Circle(pc),a0
  27.     sub.l    a1,a1
  28.     CALL    Init
  29.     move.l    d0,PIC_Circle
  30.     beq    .Exit
  31.  
  32.     move.l    PIC_Circle(pc),a0
  33.     move.l    PIC_Bitmap(a0),a0
  34.     move.l    a0,BmpC1
  35.     move.l    a0,BmpC2
  36.     move.l    a0,BmpC3
  37.  
  38.     ;Initialise the Screen.
  39.  
  40.     lea    ScreenTags(pc),a0
  41.     sub.l    a1,a1
  42.     CALL    Init
  43.     tst.l    d0
  44.     beq.s    .Exit
  45.  
  46.     ;Initialise the Bobs.
  47.  
  48.     lea    BOB_List(pc),a0
  49.     move.l    Screen(pc),a1
  50.     CALL    Init
  51.     tst.l    d0
  52.     beq.s    .Exit
  53.  
  54.     move.l    BOB_Circle1(pc),BLC1
  55.     move.l    BOB_Circle2(pc),BLC2
  56.     move.l    BOB_Circle3(pc),BLC3
  57.  
  58.     lea    RestoreTags(pc),a0
  59.     move.l    Screen(pc),a1    ;a1 = Screen.
  60.     CALL    Init    ;>> = Initialise the restore list.
  61.     tst.l    d0    ;d0 = Check for errors.
  62.     beq.s    .Exit    ;>> = Error, exit.
  63.  
  64.     moveq    #ID_JOYDATA,d0    ;Get joydata structure.
  65.     CALL    Get
  66.     move.l    d0,JoyData
  67.     beq.s    .Exit
  68.     move.l    d0,a0    ;Initialise the joydata structure.
  69.     sub.l    a1,a1
  70.     CALL    Init
  71.     tst.l    d0
  72.     beq.s    .Exit
  73.  
  74.     move.l    Screen(pc),a0
  75.     CALL    Show
  76.  
  77.     bsr.s    Main
  78.  
  79. .Exit    move.l    DPKBase(pc),a6
  80.     move.l    JoyData(pc),a0
  81.     CALL    Free
  82.     move.l    Restore(pc),a0
  83.     CALL    Free
  84.     lea    BOB_List(pc),a0
  85.     CALL    Free
  86.     move.l    Screen(pc),a0
  87.     CALL    Free
  88.     move.l    PIC_Circle(pc),a0
  89.     CALL    Free
  90.     MOVEM.L    (SP)+,A0-A6/D1-D7
  91.     moveq    #ERR_OK,d0
  92.     rts
  93.  
  94. ;===========================================================================;
  95. ;                                MAIN LOOP
  96. ;===========================================================================;
  97.  
  98. Main:    moveq    #$00,d7
  99.  
  100. .loop    move.l    DPKBase(pc),a6
  101.     move.l    JoyData(pc),a0
  102.     CALL    Query    ;Go get port status.
  103.     move.l    JoyData(pc),a0
  104.  
  105.     move.l    BOB_Circle1(pc),a1
  106.     move.w    JD_XChange(a0),d0
  107.     add.w    d0,BOB_XCoord(a1)
  108.     move.w    JD_YChange(a0),d0
  109.     add.w    d0,BOB_YCoord(a1)
  110.     move.l    JD_Buttons(a0),d0
  111.     btst    #JB_LMB,d0
  112.     bne.s    .done
  113.  
  114.     move.l    Screen(pc),a0
  115.     move.l    BOB_Circle2(pc),a1
  116.     movem.w    Circle2XV(pc),d0/d1
  117.     bsr.s    MoveBob
  118.     movem.w    d0/d1,Circle2XV
  119.  
  120.     move.l    BOB_Circle3(pc),a1
  121.     movem.w    Circle3XV(pc),d0/d1
  122.     bsr.s    MoveBob
  123.     movem.w    d0/d1,Circle3XV
  124.  
  125. .draw    move.l    Restore(pc),a0
  126.     CALL    Activate    ;Clear all buffered bob's.
  127.  
  128.     move.l    BLTBase(pc),a6
  129.     lea    BOB_List(pc),a1
  130.     CALL    bltDrawBobList    ;Go and draw all circles.
  131.  
  132.     move.l    SCRBase(pc),a6
  133.     CALL    scrWaitAVBL
  134.  
  135.     move.l    Screen(pc),a0
  136.     CALL    scrSwapBuffers
  137.     bra.s    .loop
  138.  
  139. .done    rts
  140.  
  141. ;===========================================================================;
  142. ;                              MOVE A BOB
  143. ;===========================================================================;
  144. ;Function: Moves a bob, bouncing it across the screen.
  145. ;Requires: a1 = Bob to move.
  146. ;       d0 = X Velocity
  147. ;       d1 = Y Velocity
  148. ;Returns:  d0 = New X Velocity.
  149. ;       d1 = New Y Velocity.
  150.  
  151. MoveBob:
  152.     move.l    BOB_DestBitmap(a1),a2
  153.     add.w    d0,BOB_XCoord(a1)
  154.     add.w    d1,BOB_YCoord(a1)
  155.  
  156. .ChkLX    tst.w    BOB_XCoord(a1)
  157.     bgt.s    .ChkTY
  158.     neg.w    BOB_XCoord(a1)
  159.     neg.w    d0
  160.  
  161. .ChkTY    tst.w    BOB_YCoord(a1)
  162.     bgt.s    .ChkRX
  163.     neg.w    BOB_YCoord(a1)
  164.     neg.w    d1
  165.  
  166. .ChkRX    move.w    BMP_Width(a2),d2
  167.     sub.w    BOB_Width(a1),d2
  168.     cmp.w    BOB_XCoord(a1),d2
  169.     bgt.s    .ChkBY
  170.     move.w    d2,BOB_XCoord(a1)
  171.     neg.w    d0
  172.  
  173. .ChkBY    move.w    BMP_Height(a2),d2
  174.     sub.w    BOB_Height(a1),d2
  175.     cmp.w    BOB_YCoord(a1),d2
  176.     bgt.s    .done
  177.     move.w    d2,BOB_YCoord(a1)
  178.     neg.w    d1
  179. .done    rts
  180.  
  181. ;===========================================================================;
  182. ;                                  DATA
  183. ;===========================================================================;
  184.  
  185. Circle2XV:    dc.w  +3
  186. Circle2YV:    dc.w  +2
  187. Circle3XV:    dc.w  -2
  188. Circle3YV:    dc.w  -4
  189.  
  190. JoyData:    dc.l  0
  191.  
  192. ;---------------------------------------------------------------------------;
  193.  
  194. RestoreTags:    dc.l  TAGS_RESTORE
  195. Restore:    dc.l  0
  196.         dc.l  RSA_Entries,3
  197.         dc.l  TAGEND
  198.  
  199. ;---------------------------------------------------------------------------;
  200.  
  201. ScreenTags:    dc.l  TAGS_SCREEN
  202. Screen:        dc.l  0
  203.         dc.l  GSA_Width,640
  204.         dc.l  GSA_Height,512
  205.         dc.l  GSA_Attrib,SCR_DBLBUFFER
  206.         dc.l  GSA_ScrMode,SM_LACED|SM_HIRES
  207.         dc.l    GSA_BitmapTags,0
  208.         dc.l    BMA_Planes,3
  209.         dc.l    BMA_Palette,.palette
  210.         dc.l    BMA_Type,PLANAR
  211.         dc.l    TAGEND,0
  212.         dc.l  TAGEND
  213.  
  214. .palette    dc.l  PALETTE_ARRAY,8
  215.         dc.l  $000000,$f00000,$00f000,$f0f000
  216.         dc.l  $0000f0,$f000f0,$00f0f0,$f0f0f0
  217.  
  218. ;---------------------------------------------------------------------------;
  219.  
  220. BOB_List:    dc.l  LIST1
  221. BLC1:        dc.l  TAGS_Circle1
  222. BLC2:        dc.l  TAGS_Circle2
  223. BLC3:        dc.l  TAGS_Circle3
  224.         dc.l  LISTEND
  225.  
  226. TAGS_Circle1:    dc.l  TAGS_BOB
  227. BOB_Circle1:    dc.l  0
  228.         dc.l  BBA_GfxCoords,CircleCoords
  229.         dc.l  BBA_MaskCoords,CircleCoords
  230.         dc.l  BBA_Width,96
  231.         dc.l  BBA_Height,83
  232.         dc.l  BBA_XCoord,100
  233.         dc.l  BBA_YCoord,40
  234.         dc.l  BBA_FPlane,1
  235.         dc.l  BBA_Attrib,BBF_CLIP|BBF_MASK|BBF_CLEAR|BBF_CLRNOMASK
  236.         dc.l  BBA_SrcBitmap
  237. BmpC1:        dc.l  0
  238.         dc.l  TAGEND
  239.  
  240. TAGS_Circle2:    dc.l  TAGS_BOB
  241. BOB_Circle2:    dc.l  0
  242.         dc.l  BBA_GfxCoords,CircleCoords
  243.         dc.l  BBA_MaskCoords,CircleCoords
  244.         dc.l  BBA_Width,96
  245.         dc.l  BBA_Height,83
  246.         dc.l  BBA_XCoord,278
  247.         dc.l  BBA_YCoord,86
  248.         dc.l  BBA_FPlane,0
  249.         dc.l  BBA_Attrib,BBF_CLEAR|BBF_CLRNOMASK|BBF_CLIP
  250.         dc.l  BBA_SrcBitmap
  251. BmpC2:        dc.l  0
  252.         dc.l  TAGEND
  253.  
  254. TAGS_Circle3:    dc.l  TAGS_BOB
  255. BOB_Circle3:    dc.l  0
  256.         dc.l  BBA_GfxCoords,CircleCoords
  257.         dc.l  BBA_MaskCoords,CircleCoords
  258.         dc.l  BBA_Width,96
  259.         dc.l  BBA_Height,83
  260.         dc.l  BBA_XCoord,450
  261.         dc.l  BBA_YCoord,150
  262.         dc.l  BBA_FPlane,2
  263.         dc.l  BBA_Attrib,BBF_CLEAR|BBF_CLRNOMASK|BBF_CLIP
  264.         dc.l  BBA_SrcBitmap
  265. BmpC3:        dc.l  0
  266.         dc.l  TAGEND
  267.  
  268. CircleCoords:    dc.w  0,0
  269.         dc.l  -1
  270.  
  271. ;===========================================================================;
  272.  
  273. TAGS_Circle:    dc.l  TAGS_PICTURE
  274. PIC_Circle:    dc.l  0
  275.         dc.l  PCA_Source,CircleFile
  276.         dc.l    PCA_BitmapTags,0
  277.         dc.l    BMA_Type,PLANAR
  278.         dc.l    BMA_Planes,1
  279.         dc.l    BMA_MemType,MEM_BLIT
  280.         dc.l    TAGEND,0
  281.         dc.l  TAGEND
  282.  
  283.  
  284. CircleFile:    FILENAME "GMS:Demos/Data/PIC.Circle"
  285.  
  286. ;===========================================================================;
  287.  
  288. ProgName:    dc.b  "Transparency Demo",0
  289. ProgAuthor:    dc.b  "Paul Manias",0
  290. ProgDate:    dc.b  "March 1998",0
  291. ProgCopyright:    dc.b  "DreamWorld Productions (c) 1996-1998.  Freely distributable.",0
  292. ProgShort:    dc.b  "Planar transparency demonstration.",0
  293.         even
  294.  
  295.